package inftel.android;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;

public class EditPerfil extends Activity {
    

	protected static EditText email;
	protected static EditText pass;
	protected static EditText direccion;
	protected static RadioButton sexo;
	
	protected static EditText ciudadOrigen;
	protected static EditText ciudadActual;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.editperfil); 
		email = (EditText) findViewById(R.id.editText1);
		pass = (EditText) findViewById(R.id.editText2);
		direccion = (EditText) findViewById(R.id.editText3);
		sexo = (RadioButton) findViewById(R.id.radioButton2);
		
		ciudadOrigen = (EditText) findViewById(R.id.editText5);
		ciudadActual = (EditText) findViewById(R.id.editText6);
		Button modificar = (Button) findViewById(R.id.editar_perfil_button1);
		
		modificar.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				
				try{
					
					String url = "http://192.168.183.64:8080/caralibro-war/modificarPerfil?email="
						 +email.getText().toString() +"&pass="+pass.getText().toString()+"&direccion="+direccion.getText().toString()
						 +"&sexo="+sexo.getText().toString()+"&ciudadOrigen="+ciudadOrigen.getText().toString()
						 +"&ciudadActual="+ciudadActual.getText().toString()+"&usuario="+5;
					Log.println(Log.DEBUG, "", "url = " + url);
					URL ob = new URL(url);
								
								
				                
				                URLConnection    conn = ob.openConnection(); 
				                
				                conn.setDoInput(true); 
				                conn.setDoOutput(true);
				                InputStream in = conn.getInputStream();
				                OutputStream out =conn.getOutputStream();
				                DataInputStream dos =  new DataInputStream(in);
				                
				                //String leido = dos.readUTF();

				                dos.close(); 
				                conn=null;
							}catch(Exception e){
								e.printStackTrace();
							}
						}
		});	
	}
}


